package net.kem.android.positioner;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ImageButton buMap = (ImageButton)findViewById(R.id.imageButtonMap);
        buMap.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				Intent positionerActivity = new Intent(getBaseContext(), PositionerActivity.class);
				startActivity(positionerActivity);
			}
		});

        ImageButton buSettings = (ImageButton)findViewById(R.id.imageButtonSettings);
        buSettings.setOnClickListener(new OnClickListener() {
        	public void onClick(View view) {
        		Intent iSA = new Intent(getBaseContext(), PreferencesFromXml.class);
    			startActivity(iSA);
        	}
        });

        ImageButton buServerMessages = (ImageButton)findViewById(R.id.imageButtonServerMessages);
        buServerMessages.setOnClickListener(new OnClickListener() {
        	public void onClick(View view) {
        		Intent iSA = new Intent(getBaseContext(), ServerMessagesActivity.class);
        		startActivity(iSA);
        	}
        });

        ImageButton buExit = (ImageButton)findViewById(R.id.imageButtonExit);
        buExit.setOnClickListener(new OnClickListener() {
        	public void onClick(View view) {
        		finish();
        	}
        });

        Settings.init(this); // Initialize Setting instance.

        // Make PositionerService running indefinitely.
        startService(new Intent(this, PositionerService.class));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}
